﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace ZhiAo.CoreLibrary.ECIAssembly
{
   public  class AssemblyManage
    {
       public static Assembly Load(string assemblyPath)
       {
           Assembly assembly = null;
           FileInfo fileInfo = new FileInfo(assemblyPath);
           string dllName = fileInfo.Name.Replace(".dll", "");
           if (PlatformInfo.DevelopMode)
           {
               assembly = System.Reflection.Assembly.Load(dllName);
               if (ZhiAo.CoreLibrary.PlatformInfo.DevelopMode)
               {
                   LOG.Write(dllName, "AssemblyManage");
               }
           }
           else
           {
               FileStream fs = File.OpenRead(assemblyPath);
               byte[] array = new byte[fs.Length];
               fs.Read(array, 0, Convert.ToInt32(fs.Length));
               assembly = Assembly.Load(array);
               fs.Close();
           }
           return assembly;
       }
    }
}
